package com.csi.bumblebee.service.impl;

import com.csi.bumblebee.domain.dictionary.Major;
import com.csi.bumblebee.domain.dictionary.School;
import com.csi.bumblebee.mapper.MajorMapper;
import com.csi.bumblebee.service.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 孙伟俊
 */
@Service
public class MajorServiceImpl implements MajorService {

    @Autowired
    private MajorMapper majorMapper;

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public Major findNameById(String id) {
        return null;
    }

    /**
     * 展示全部
     * @return List<Major>
     */
    @Override
    public List<Major> list() {

        List<Major> majorList = (List<Major>) redisTemplate.opsForValue().get("majors");

        if (majorList != null) {
            return majorList;
        }else {
            majorList = majorMapper.list();
            redisTemplate.opsForValue().set("majors", majorList);
            return majorList;
        }
    }

    @Override
    public List<Major> listFirstClass() {
        return null;
    }

    @Override
    public List<Major> listSecondClass(String fatherId) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Major major) {
        return 0;
    }

    @Override
    public int deleteByPrimaryKey(String id) {
        return 0;
    }

    @Override
    public int insertSelective(Major major) {
        return 0;
    }

    @Override
    public List<Major> listMajorTree() {
        return majorMapper.listMajorTree();
    }
}
